<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>在籍会员列表</title>
    {include file="common/linkcss" /}
</head>


<body>

    <div class="container-fluid">
        <div class="row">

            {include file="common/sidebar" /}

            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="card border-primary  ">
                    <div class="card-header">
                        <h1 class="page-header">
                            在籍会员列表
                        </h1>
                        <!-- <a href="{:url('add')}" class="btn btn-success">导出所有用户数据</a> -->
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th scope="col">编号</th>
                                        <th scope="col">姓名</th>
                                        <th scope="col">手机号</th>
                                        <th scope="col">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name="user" id="vo"}
                                    <tr id="tr{$vo.id}">
                                        <th scope="row">{$vo.id}</th>
                                        <td>{$vo.name}</td>
                                        <td>{$vo.phone}</td>
                                        <td scope="row">
                                            <a href="{:url('user/edit',array('id'=>$vo['id']))}" class="btn btn-primary btn-sm">编辑</a>
                                            <a href="{:url('user/edit',array('id'=>$vo['id']))}" class="btn btn-info btn-sm">查看他的所有订单</a>
                                            <button type="button" class="btn btn-danger btn-sm" onclick="delThis('{$vo.id}')">删除</button>
                                        </td>
                                    </tr>
                                    {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <!-- main end -->


        </div>
    </div>
    <!-- container end -->

    <script>
        function delThis($id) {
            confirm('警告', '你正在进行删除操作，一旦删除将无法挽回！', function (isConfirm) {
                if (isConfirm) {
                    $.post("{:url('user/del')}",
                        {
                            id: $id,
                        },
                        function (data, status) {
                            if (data == 1) {
                                alert("提示!", "已成功为你删除", function () {
                                    $('#tr' + $id).remove();
                                }, {
                                    type: 'success',
                                    confirmButtonText: '确定'
                                });
                            }
                        }
                    );
                }
            }, {
                confirmButtonText: '我确定',
                cancelButtonText: '取消操作',
                width: 400
            });
        }

        function closeThis($id) {
            confirm('提示', '你确定要封禁此用户，封禁后此用户将无法享受权益', function (isConfirm) {
                if (isConfirm) {
                    $.post("{:url('user/close')}",
                        {
                            id: $id,
                            is_close: 0
                        },
                        function (data, status) {
                            if (data == 1) {
                                alert("提示!", "已成功封禁用户", function () {
                                    $('#tr' + $id).find('.is_close').addClass('badge-danger').removeClass('badge-success').text('已封禁');
                                }, {
                                    type: 'success',
                                    confirmButtonText: '确定'
                                });
                            }
                        }
                    );
                }
            }, {
                confirmButtonText: '我确定',
                cancelButtonText: '取消操作',
                width: 400
            });
        }

        function openThis($id) {
            confirm('提示', '你将解封此用户，用户恢复所有权益', function (isConfirm) {
                if (isConfirm) {
                    $.post("{:url('user/close')}",
                        {
                            id: $id,
                            is_close: 1
                        },
                        function (data, status) {
                            if (data == 1) {
                                alert("提示!", "已成功解除用户", function () {
                                    $('#tr' + $id).find('.is_close').addClass('badge-success').removeClass('badge-danger').text('正常')
                                }, {
                                    type: 'success',
                                    confirmButtonText: '确定'
                                });
                            }
                        }
                    );
                }
            }, {
                confirmButtonText: '我确定',
                cancelButtonText: '取消操作',
                width: 400
            });
        }
    </script>
</body>

</html>